"""文章分类"""
from datetime import datetime
from typing import Any, List

from pydantic import BaseModel, Field

from schemas.message_model import MessageModel


class NewsTypeBase(BaseModel):  # 与数据库表响应
    nety_name: str
    nety_intro: str


class NewsTypeCreate(NewsTypeBase):  # 创建，字段是要传入的值
    nety_name: str
    nety_intro: str


class NewsTypeRead(BaseModel):  # 读取数据
    nety_id: int
    nety_name: str
    nety_intro: str
    # created_at: datetime
    # updated_at: datetime

    class Config:
        orm_mode = True


class NewsTypeUpdate(NewsTypeBase):
    pass


class NewsTypeDelete(NewsTypeBase):
    pass

    class Config:
        """兼容ORM模型,为模型实例,为Pydantic开启验证"""
        orm_mode = True  # 方便直接从模型类的实例里创建数据


class NewsTypeOut(MessageModel):
    detail: List[NewsTypeRead] = Field(None, title="")
